<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>表格Demo</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../assets/libs/layui/css/layui.css" media="all">
</head>

<body>
    <style>
        label.layui-form-label {
            width: 90px;
        }

        div.layui-input-block {
            margin-left: 125px;
        }
    </style>
    <form class="layui-form" action="" lay-filter="example" method="POST" action="" style="padding: 20px 10px;">

        <input type="hidden" name="speedId" id="speedId">

        <div class="layui-form-item">
            <label class="layui-form-label">起始位置</label>
            <div class="layui-input-block">
                <input type="text" name="startRegion" id="startRegion" lay-verify="required" placeholder="请输入" required
                    autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">终点位置</label>
            <div class="layui-input-block">
                <input type="text" name="endRegion" id="endRegion" lay-verify="required" placeholder="请输入" required
                    autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">高铁日期</label>
            <div class="layui-input-block">
                <input name="speedDate" id="speedDate" required lay-verify="required" placeholder="请输入" required
                    class="layui-input"></input>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">高铁时间</label>
            <div class="layui-input-block">
                <input name="speedTime" id="speedTime" required lay-verify="required" placeholder="请输入" required
                    class="layui-input"></input>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">票价</label>
            <div class="layui-input-block">
                <input type="number" name="speedMon" id="speedMon" lay-verify="required" placeholder="请输入" required
                    autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">车厢数目</label>
            <div class="layui-input-block">
                <input type="number" name="speedSection" id="speedSection" lay-verify="required" placeholder="请输入"
                    required autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">车厢座位排数</label>
            <div class="layui-input-block">
                <input type="number" name="speedRow" id="speedRow" lay-verify="required" placeholder="请输入" required
                    autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" style="margin: auto;">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" id="submit" lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <style>
        .layui-upload-list {
            padding: 10px 40px;
            display: flex;
            min-height: 150px;
            min-width: 150px;
            border: 1px solid #cccccc;
        }

        .imgitem {
            cursor: pointer;
            background-color: #FF5722;
            ;
            width: 100%;
            text-align: center;
        }

        .imgBox {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            margin: 0px 20px;
        }
    </style>
    <script src="../../assets/libs/layui/layui.js" charset="utf-8"></script>
    <script src="../js/util.js" charset="utf-8"></script>

    <script>
        layui.config({
            base: '/module/'
        }).extend({

        }).use(['upload', 'config', 'form', 'jquery', 'laydate'], function () {
            var config = layui.config;
            var form = layui.form;
            var $ = layui.jquery;
            var laydate = layui.laydate;

            var req = GetRequest();
            var no = req['editNo'];

            $.ajax({
                url: config.base_server + 'getSpeedById?editNo=' + no,
                dataType: 'json',
                type: 'get',
                success: function (data) {
                    data = data.data;
                    $('#speedId').val(data.speedId);
                    $('#startRegion').val(data.startRegion);
                    $('#endRegion').val(data.endRegion);
                    $('#speedMon').val(data.speedMon);
                    $('#speedPollall').val(data.speedPollall)
                    $('#speedPolleave').val(data.speedPolleave)
                    $('#speedSection').val(data.speedSection)
                    $('#speedRow').val(data.speedRow)

                    laydate.render({
                        elem: '#speedDate',
                        value: new Date()
                        , type: 'date'
                        , trigger: 'click'
                        , value: data.speedDate
                    });

                    laydate.render({
                        elem: '#speedTime',
                        value: new Date()
                        , type: 'time'
                        , trigger: 'click'
                        , format: 'HH:mm'
                        , value: data.speedTime
                    });
                }
            })


            $('#submit').on('click', function () {
                var data = form.val('example');
                $.ajax({
                    type: "POST",
                    url: config.base_server + "updataSpeed",
                    async: false,
                    data: data,
                    success: function (data) {
                        if (data.code == 1) {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            alert("修改成功");
                            parent.layer.close(index); //再执行关闭   
                        } else {
                            alert(data.msg);
                        }
                    },
                    error() {
                        alert("文件太大")
                    }
                });
                return false;
            });

        });
    </script>


</body>